import request from '../../utils/request.js'
const state = {
	recommendList: [],
	productItems:[]
}
const mutations = {
	SET_RECOMMENDLIST(state,recommendList){
		state.recommendList=recommendList
	},
	ADD_RECOMMENDLIST(state,recommend){
		state.recommendList.push(...recommend)
	},
	SET_PRODUCTITEMS(state,productItems){
		state.productItems=productItems
	},
	ADD_ONE_PRODUCTITEMS(state,goods){
		state.productItems.push(goods)
	},
	REMOVE_ONE_PRODUCTITEMS(state,index){
		state.productItems.splice(index,1)
	}

}
const actions = {
	async getRecommendList({commit}){
		const result = await request('/getRecommendList')
		commit('SET_RECOMMENDLIST',result)
	},
	async getProductItems({commit}){
		const result = await request('/getProductItems')
		commit('SET_PRODUCTITEMS',result)
	}
}
const getters = {

}

export default {
	state,
	mutations,
	actions,
	getters,
}
